//
//  SSDemoViewController.m
//  PopupView
//
//  Created by 石少庸 on 2017/8/2.
//  Copyright © 2017年 BAHome. All rights reserved.
//

#import "SSDemoViewController.h"
#import "SSPopupView.h"

#define kWidth [UIScreen mainScreen].bounds.size.width
#define kHeight [UIScreen mainScreen].bounds.size.height

@interface SSDemoViewController ()
@property (strong, nonatomic) SSPopupView *popView;
@end

@implementation SSDemoViewController

#pragma mark - LifeCycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // test view
    UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 100)];
    testView.backgroundColor = [UIColor orangeColor];
    
    // init pop
    _popView = [SSPopupView popupWithContentView:testView];
}

#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section == 0) {
        switch (indexPath.row) {
            case 0: {
                [self clearAction];
                [_popView showWithLayout:SSPopupLayoutCenter];
            }
                break;
            case 1: {
                [self fadeAction];
                [_popView showWithLayout:SSPopupLayoutMake(SSPopupHorizontalLayoutCenter, SSPopupVerticalLayoutBottom)];
            }
                break;
        }
    }
    
    if (indexPath.section == 1) {
        switch (indexPath.row) {
            case 0: {
                _popView.showType = SSPopupShowTypeSlideInFromLeft;
                _popView.dismissType = SSPopupDismissTypeSlideOutToLeft;
                [_popView showWithLayout:SSPopupLayoutCenter];
            }
                break;
                
        }
    }
}

#pragma mark - Private

- (void)clearAction {
    _popView.showType = SSPopupShowTypeNone;
    _popView.dismissType = SSPopupDismissTypeNone;
}

- (void)fadeAction {
    _popView.showType = SSPopupShowTypeFadeIn;
    _popView.dismissType = SSPopupDismissTypeFadeOut;
}

@end
